package com.xiang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiang.doman.Account;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface AccountMapper extends BaseMapper<Account> {

    //try
    @Update(" update t_account set money = money - #{amount}, transfer =transfer + #{amount} where id = #{accountId}")
    void reduceMoney(@Param("amount") double amount,@Param("accountId") int accountId);

    //commit
    @Update("update t_account set transfer= transfer - #{amount} where id = #{accountId}")
    void commitReduce(@Param("amount") double amount,@Param("accountId") int accountId);

    //cancle
    @Update("update t_account set money = money + #{amount}, transfer = transfer - #{amount} where id = #{accountId}")
    void  cancleReduce(@Param("amount") double amount,@Param("accountId") int accountId);

}
